package jsyf.oa.dao.device;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import jsyf.oa.entity.device.DeviceTransportChangeEntity;
import jsyf.oa.idao.BaseDao;
import jsyf.oa.ientity.IBaseEntity;
import org.springframework.stereotype.Repository;

/**
 * Created by 92852 on 2018/7/11.
 */
@Repository
public class DeviceTransportChangeDao  extends BaseDao {
    public DeviceTransportChangeDao() {
        super.iBaseEntity = new DeviceTransportChangeEntity();
    }

    @Override
    public IBaseEntity convertJson2Entity(JSONObject json) {
        return JSON.toJavaObject(json, DeviceTransportChangeEntity.class);
    }
    public JSONObject getChangeByDeviceId(String condition) {
        StringBuffer sql= new StringBuffer();
        sql.append("SELECT\n" +
                "ID AS id,\n" +
                "CHANGE_REASON AS changeReason,\n" +
                "DEVICE_ID AS deviceId,\n" +
                "NEW_DEPARTURE AS newDeparture,\n" +
                "DESTINATION AS destination,\n" +
                "TRANSPORT_COMPANY AS transportCompany,\n" +
                "TRA_COM_CONTACT_NAME AS traComContactName,\n" +
                "TRA_COM_CONTACT_TEL AS traComContactTel,\n" +
                "MODEL_CAR_LICENSE AS modelCarLicense,\n" +
                "DRIVER_NAME AS driverName,\n" +
                "DRIVER_TEL AS driverTel,\n" +
                "FREIGHT AS freight,\n" +
                "DEDUCTION AS deduction,\n" +
                "DEDUCTION_INSTRUCTIONS AS deductionInstructions,\n" +
                "CMODEL_CAR_PHOTO_NAME AS cmodelCarPhotoName,\n" +
                "CMODEL_CAR_PHOTO_URL AS cmodelCarPhotoUrl,\n" +
                "CDRIVER_CERTIFICATE_URL AS cdriverCertificateUrl,\n" +
                "CDRIVER_CERTIFICATE_NAME AS cdriverCertificateName,\n" +
                "CDEVICE_PHOTO_URL AS cdevicePhotoUrl,\n" +
                "CDEVICE_PHOTO_NAME AS cdevicePhotoName\n" +
                "FROM\n" +
                "t_dvc_transport_change\n" +
                "WHERE 1=1\n");
        sql.append(condition);
        JSONObject changeObj= super.queryForJsonObject(sql.toString());
        return changeObj;
    }

}
